package pro.cherish.smartfile.common.enums;

import pro.cherish.smartfile.util.MapHelper;

import java.util.Arrays;
import java.util.Map;

public interface BaseEnum extends IEnum<String> {

    static Map<String, String> getMap(BaseEnum[] list) {
        return MapHelper.uniqueIndex(Arrays.asList(list), BaseEnum::getCode, BaseEnum::getDesc);
    }

    default String getCode() {
        return this.toString();
    }

    String getDesc();

    default boolean eq(String val) {
        return this.getCode().equalsIgnoreCase(val);
    }

    @Override
    default String getValue() {
        return this.getCode();
    }
}
